#include "behavior_tree_if_then_else_policy.h"
#include <behaviortree_cpp_v3/controls/if_then_else_node.h>

namespace policy
{

BehaviorTreeIfThenElsePolicy::BehaviorTreeIfThenElsePolicy(const std::string &name)
    : BehaviorTreePolicy(name)
{
    policy_tree_node_ = std::make_unique<BT::IfThenElseNode>(name + "_fallback_node");
}
BehaviorTreeIfThenElsePolicy::~BehaviorTreeIfThenElsePolicy() = default;

bool BehaviorTreeIfThenElsePolicy::setConditionTask(const task::AbstractTaskConstPtr &task)
{
    return BehaviorTreePolicy::insertTask(0, task);
}
bool BehaviorTreeIfThenElsePolicy::setConditionPolicy(const AbstractPolicyConstPtr &policy)
{
    return BehaviorTreePolicy::insertPolicy(0, policy);
}
bool BehaviorTreeIfThenElsePolicy::setThenTask(const task::AbstractTaskConstPtr &task)
{
    return BehaviorTreePolicy::insertTask(1, task);
}
bool BehaviorTreeIfThenElsePolicy::setThenPolicy(const AbstractPolicyConstPtr &policy)
{
    return BehaviorTreePolicy::insertPolicy(1, policy);
}
bool BehaviorTreeIfThenElsePolicy::setElseTask(const task::AbstractTaskConstPtr &task)
{
    return BehaviorTreePolicy::insertTask(2, task);
}
bool BehaviorTreeIfThenElsePolicy::setElsePolicy(const AbstractPolicyConstPtr &policy)
{
    return BehaviorTreePolicy::insertPolicy(2, policy);
}
}
